#include "settingspanel.h"

Settingspanel::Settingspanel() : Panel(false)
{
// 	isTouchable = true;
// 	isTransparant = true;
// 	zaxis = 0;

	col1 = 10;
	col2 = 200;
	col3 = 280;
	row = 10;
	rowspacer = 12;
}

void Settingspanel::addSection( const std::string& name, unsigned int posx, unsigned int posy )
{
	std::string str(name);

// 	row += 3;
	addWidgetText( str, posx+col1, posy+row+9, name );
	row += rowspacer;
}

void Settingspanel::addMutator( const std::string& name, const cmdsettings& cmd1, const cmdsettings& cmd2, unsigned int posx, unsigned int posy )
{
	std::string str(name); std::string strval = str; std::string strdec = str; std::string strinc = str;
	strval.append("val"); strdec.append("dec"); strinc.append("inc");

	addWidgetText( str, posx+col1, posy+row+9, name );
	addWidgetText( strval, posx+col2, posy+row+9, settings->getCVarPtr(name) );
	addWidgetButton( strdec, Vector2i(posx+col3, posy+row), Vector2i(11, 10), "-", Vector2i(3, 8), cmd1, EVENT_REPEAT, 150 );
	addWidgetButton( strinc, Vector2i(posx+col3+18, posy+row), Vector2i(11, 10), "+", Vector2i(1, 8), cmd2, EVENT_REPEAT, 150 );
	row += rowspacer;
}

void Settingspanel::addSettingmutator( const std::string& name, unsigned int posx, unsigned int posy )
{
	std::string str(name); std::string strval = str; std::string strdec = str; std::string strinc = str;
	strval.append("val"); strdec.append("dec"); strinc.append("inc");

	addWidgetText( str, posx+col1, posy+row+9, name );
	addWidgetText( strval, posx+col2, posy+row+9, settings->getCVarPtr(name) );
	addWidgetButton( strdec, Vector2i(posx+col3, posy+row), Vector2i(11, 10), "-", Vector2i(3, 8), cmd.gen("settings_decrease", name), EVENT_REPEAT, 150 );
	addWidgetButton( strinc, Vector2i(posx+col3+18, posy+row), Vector2i(11, 10), "+", Vector2i(1, 8), cmd.gen("settings_increase", name), EVENT_REPEAT, 150 );
	row += rowspacer;
}

void Settingspanel::addCheckbox( const std::string& name, const cmdsettings& cmd1, unsigned int posx, unsigned int posy )
{
	std::string str(name);
	std::string strinc(str);
	strinc.append("inc");

	addWidgetText( str, posx+col1+23, posy+row+9, name );
	addWidgetCheckbox( strinc, Vector2i(posx+col1, posy+row), Vector2i(11, 10), "x", Vector2i(3, 8), cmd1, name, EVENT_NOREPEAT, 0 );
	row += rowspacer;
}

void Settingspanel::addSettingcheckbox( const std::string& name, unsigned int posx, unsigned int posy )
{
	std::string str(name);
	std::string strinc(str);
	strinc.append("inc");

	addWidgetText( str, posx+col1+23, posy+row+9, name );
	addWidgetCheckbox( strinc, Vector2i(posx+col1, posy+row), Vector2i(11, 10), "x", Vector2i(3, 8), cmd.gen("settings_increase", name), EVENT_NOREPEAT, 0 );
	row += rowspacer;
}

Settingspanel::~Settingspanel()
{
}
